//	 Copyright 2011 Elian ORIOU
//
//   Licensed under the Apache License, Version 2.0 (the "License");
//   you may not use this file except in compliance with the License.
//   You may obtain a copy of the License at
//
//       http://www.apache.org/licenses/LICENSE-2.0
//
//   Unless required by applicable law or agreed to in writing, software
//   distributed under the License is distributed on an "AS IS" BASIS,
//   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
//   See the License for the specific language governing permissions and
//   limitations under the License.

package org.eo.geomapper.objects;

import java.awt.Color;
import java.util.ArrayList;
import java.util.List;

/**
 * A simple implementation of a geographical layer
 * 
 * @author Elian ORIOU
 * 
 */

public class SimpleLayer implements ILayer {

	private String name;
	private ObjectType objectType;
	private List<IObject> objects;
	private Color color;

	public SimpleLayer(String name, ObjectType objectType, Color color) {
		this.name = name;
		this.objectType = objectType;
		this.objects = new ArrayList<IObject>();
		this.color = color;
	}

	/**
	 * Returns the name of the object
	 * 
	 * @return the name of the object
	 */

	@Override
	public String getName() {
		return this.name;
	}

	/**
	 * Sets the name of the object
	 * 
	 * @param name
	 *            the new name of the object
	 */

	@Override
	public void setName(String name) {
		this.name = name;
	}

	/**
	 * Returns the type of the object
	 * 
	 * @return the type of the object
	 */

	@Override
	public ObjectType getObjectType() {
		return this.objectType;
	}

	/**
	 * Sets the type of the object
	 * 
	 * @param type
	 *            the new object type
	 */

	@Override
	public void setObjectType(ObjectType type) {
		this.objectType = type;
	}

	/**
	 * Adds a object on the layer
	 * 
	 * @param object
	 *            the object to add
	 */

	@Override
	public void addObject(IObject object) {
		this.objects.add(object);
	}

	/**
	 * Returns the list of objects attached on the layer
	 * 
	 * @return the list of objects attached on the layer
	 */

	@Override
	public List<IObject> getObjects() {
		return this.objects;
	}

	/**
	 * Sets the layer color
	 * 
	 * @param color
	 *            the new layer color
	 */

	@Override
	public void setColor(Color color) {
		this.color = color;
	}

	/**
	 * Returns the layer color
	 * 
	 * @return the layer color
	 */

	@Override
	public Color getColor() {
		return color;
	}

	@Override
	public String toString() {
		return "SimpleLayer [color=" + color + ", name=" + name
				+ ", objectType=" + objectType + ", objects=" + objects + "]";
	}
}
